<template>
	<view class="content">
		<view class="cabilnet-list">
			<view class="cabilnet-li" @click="isCabilnet(item.id,item.name)" v-for="(item,index) in shoeList"
				:key="index">
				<view class="cabilnet-li-l">
					<image src="https://www.sdxiecheng.cn/img/address.png" mode=""></image>
					<view class="cabilnet-info">
						<view class="title">{{ item.name }} 空柜 <text>({{ item.freenum }})</text></view>
						<view class="address">{{ item.address}}</view>
					</view>
				</view>
				<view class="cabilnet-li-r">
					<button class="u-reset-button">选择</button>
					<view class="juli">
						<image src="https://www.sdxiecheng.cn/img/daohang.png" mode=""></image>
						<text>{{ item.distance }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: '',
				longitude: '',
				shoeList: []
			}
		},
		onShow() {
			this.getAddress()
		},
		methods: {
			isCabilnet(id, title) {
				uni.navigateBack({
					delta: 1
				})
				uni.$emit('update', {
					id: id,
					title: title
				})
			},
			getAddress() {
				let that = this
				uni.getLocation({
					type: 'gcj02',
					success: function(res) {
						that.latitude = res.latitude
						that.longitude = res.longitude
						that.getShoeList()
					},
					fail: function(res) {
						console.log(res)
					}
				});
			},
			// 选择柜体列表接口
			getShoeList() {

				uni.$u.http.post('/shoe/index', {
					longitude: this.longitude,
					latitude: this.latitude
				}).then(res => {
					// console.log(res,'哈哈哈哈')
					this.shoeList = res.data
				}).catch(err => {
				})
			}
		},
		onShareAppMessage(res) {
		    if (res.from === 'button') {// 来自页面内分享按钮
		      console.log(res.target)
		    }
		    return {
		      title: '鞋橙洗护，您身边的洗护专家',
		      path: '/pages/index/index'
		    }
		  },
	}
</script>

<style lang="less">
	.content {
		padding: 20rpx;
	}

	.cabilnet-li {
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-left: 20rpx;
		padding-right: 17rpx;
		height: 150rpx;

		.cabilnet-li-l {
			display: flex;
			align-items: center;

			image {
				width: 37rpx;
				height: 46rpx;
				margin-right: 20rpx;
			}

			.title {
				font-size: 28rpx;
				font-weight: bold;
				margin-bottom: 9rpx;

				text {
					color: #FBAA27;
					margin-left: 8rpx;
				}
			}

			.address {
				font-size: 24rpx;
				color: #7C7C7C;
			}
		}

		.cabilnet-li-r {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;

			image {
				width: 29rpx;
				height: 27rpx;
			}

			button {
				width: 150rpx;
				height: 46rpx;
				background: #FBAA27;
				border-radius: 23rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
				margin-bottom: 16rpx;
			}

			.juli {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #7C7C7C;

				image {
					margin-right: 9rpx;
				}
			}
		}
	}
</style>
